[[http://packages.debian.org/reprepro|The reprepro package]] is tool for creating an APT repository with a pool structure, the same type of structure the official Debian mirrors use.

The repository may:

* Contain packages for multiple distributions:
  Stable, Unstable, Testing, etc.
* Contain packages for multiple architectures:
 x86, sparc, all, etc.
* Be managed quickly and easily.

----

1. Install reprepro on ubuntu

  apt-get install reprepro

2. Create directory structure
  mkdir -p /www/luna_apt_repository/apt
  mkdir -p /www/luna_apt_repository/apt/conf
  mkdir -p /www/luna_apt_repository/apt/incoming

3. Create configuration file

Now that we have a directory to contain our repository we can look at creating the configuration file. The configuration file will specify which releases the repository will contain (sid, stable, etc) as well as the architectures. A sample configuration file will look like this:

  Origin: Your Name
  Label: Your own label
  Suite: stable
  Codename: sarge
  Version: 3.1
  Architectures: i386 all source
  Components: main non-free contrib
  Description: Your description

Here we've defined a repository which only contains packages for stable/sarge, which contains packages targeted to x86, or all. If you wish to contain both stable and unstable packages your configuration file will look like this:

  Origin: Your Name
  Label: Your own label
  Suite: stable
  Codename: sarge
  Version: 3.1
  Architectures: i386 all source
  Components: main non-free contrib
  Description: Your description

  Origin: Your Name
  Label: Your own label
  Suite: unstable
  Codename: sid
  Architectures: i386 all source
  Components: main non-free contrib
  Description: Your description

Save your configuration to the file *conf/distributions* and you should now be ready to import a package.

4. Import packages

You can either import a .deb file into the repository, or a .changes file which is produced by building a package from source.

From the main directory run:

  reprepro -Vb . include sarge name_of_file

For example:

5. Config HTTP server:

Here we use nginx. This is config file:

<pre>
server {
  listen 80;
  server_name luna-updates.internal;

  access_log /var/log/nginx/packages-access.log;
  error_log /var/log/nginx/packages-error.log;

  location / {
    root /www/luna_apt_repository/apt;
    index index.html;
  }

  location ~ /(.*)/conf {
    deny all;
  }

  location ~ /(.*)/db {
    deny all;
  }
}
</pre>


----

===Using your apt repository===

Once your packages has been added to the archive they may be downloaded via apt-get, or aptitude, with the appropriate lines in your /etc/apt/sources.list file:

  deb     http://example.com/apt  sarge main contrib non-free
  deb-src http://example.com/apt  sarge main contrib non-free

If you're using two distributions simply repeat for each:
  
  deb     http://example.com/apt  sarge main contrib non-free
  deb-src http://example.com/apt  sarge main contrib non-free

  deb     http://example.com/apt  sid main contrib non-free
  deb-src http://example.com/apt  sid main contrib non-free


----

Resources:

* [[http://www.debian-administration.org/articles/286|Setting up your own APT repository with upload support]]
* [[http://davehall.com.au/blog/dave/2010/02/06/howto-setup-private-package-repository-reprepro-nginx|Howto Setup a Private Package Repository with reprepro and nginx]]